package emumTest;

import java.util.EnumSet;

/**
 * @ClassName EnumTest2
 * @Description demo1
 * @Author LIBOFEI
 * @Date 2020/6/6 17:55
 * @Version 1.0
 **/
enum Fruit{
    /***/
    APPLE{
        @Override
        void eat(){System.out.println("吃苹果");}
    },
    /***/
    pear{
        @Override
        void eat(){System.out.println("吃梨");}
    },
    /***/
    waterMelon{
        @Override
        void eat(){System.out.println("吃西瓜");}
    };
    abstract void eat();
}

public class EnumTest2 {

    EnumSet<Fruit> enumSet = EnumSet.of(Fruit.APPLE);

    void add(Fruit fruit){
        enumSet.add(fruit);
    }

    void eat(){
        for(Fruit fruit : enumSet){
            fruit.eat();
        }
    }

    public static void main(String[] args) {
        EnumTest2 test2 = new EnumTest2();
        System.out.println(test2);
        test2.eat();
        test2.add(Fruit.pear);
        test2.add(Fruit.waterMelon);
        System.out.println(test2);
        test2.eat();
    }
}
